#!/usr/bin/perl -w

use strict;
use MIME::Base64;

# This is simply a wrapper to calling the load_table routine which the
# clreq routine can do. It passes everything as is to the daemon apart from teh 
# argument following the "data" argument which it expects is a single
# record in the format "field|value|..." (enclosed in quotes or escaped |'s).
#
# It will encode the data as expected for the load_table call and then 
# exec clreq.

$::cmd="clreq ";

exit(1) if !@::ARGV;
$::i=0;
$::l=scalar(@::ARGV);
while($::i<$::l) {
	$::f=$::ARGV[$::i];
	$::cmd.="$::f ";
	if($::f eq "data") {
		$::i++;
		$::h=encode_base64($::ARGV[$::i],'');
		$::cmd.="$::h ";
	}
	$::i++;
}
print "$::cmd\n";
system("$::cmd");
